<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script type="text/javascript">
		var messages=[];
		
			var fun2=function(){
				var username=document.getElementById("username");
				var msg=document.getElementById("msg");
				var msgs=document.getElementById("msgs");
				var message="["+username.value+"]说："+msg.value+"";
				messages.unshift(message);
				if(message.length>10){
					messages.pop()
				}
				msgs.value=messages.join("\n");
			}
			function fun1(){
				var username=document.getElementById("username");
				var msg=document.getElementById("msg");
				var msgs=document.getElementById("msgs");
				username.value="";
				msg.value="";
				msgs.value="";
				messages=[];
			}
		</script>
	</head>
	<body>
		姓名：<input type="text"  id="username" /><br>
		留言：<textarea rows="3" cols="30" id = "msg" 
		style="resize: none;vertical-align: top;"></textarea><br>
		<button onclick="fun1()">重置</button>
		<button onclick="fun2()">留言</button>
		<hr>
		<textarea rows="10" cols="50" disabled="disabled" 
		id = "msgs" style="resize: none;"></textarea><br>
	</body>
</html>
